//
// Created by vcq on 21/2/9.
//
#pragma once

#include "model/judge.hpp"

static void GetJudge(request &req, response &res) {
    basic_string_view<char> id = req.get_query_value("id");
    json item = MGetJudge(id);
    res.set_status_and_content(status_type::ok, item.dump(), req_content_type::json);
}

static void SaveJudge(request &req, response &res) {
    if (!check_login(req, res)) {
        return;
    }
    struct judge judge1{};
    judge1.id = atoi(req.get_query_value("id").data());
    judge1.name = req.get_query_value("name");
    judge1.note = req.get_query_value("note");
    MAddJudge(judge1);
    res.set_status_and_content(status_type::ok);
}


static void DeleteJudge(request &req, response &res) {
    if (!check_login(req, res)) {
        return;
    }
    MDeleteJudge(req.get_query_value("id"));
    res.set_status_and_content(status_type::ok);
}
